import {createStore} from 'vuex'
import {testData, testPosts,ColumnProps,PostProps } from './testData'
interface UserProps{
  isLogin:boolean,
  name?:string,
  id?:number,
  columnId?:number
}

export interface GlobalDataProps{
  columns:ColumnProps[]
  posts:PostProps[]
  user :UserProps
}
const store=createStore<GlobalDataProps>({
  state:{
     columns:testData,
     posts:testPosts,
     user:{isLogin:true,name:'hjh,',columnId:1}
  },
  mutations:{
    login(state){
      state.user={...state.user,isLogin:true,name:'黄嘉涵~'}
    },
    createPost(state,payload){
      state.posts.push(payload)
    }
  }
})

export default store